package com.bykj.taketurns.fragment;

import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bykj.taketurns.R;
import com.bykj.taketurns.application.MyApplication;
import com.bykj.taketurns.myfragment.activity.AttentionActivity;
import com.bykj.taketurns.myfragment.activity.FansActivity;
import com.bykj.taketurns.myfragment.activity.MessageMyActivity;
import com.bykj.taketurns.myfragment.activity.PersonageMyActivity;
import com.bykj.taketurns.myfragment.activity.PlayMyActivity;
import com.bykj.taketurns.myfragment.activity.PraiseActivity;
import com.bykj.taketurns.myfragment.activity.PropertyMyActivity;
import com.bykj.taketurns.myfragment.activity.RegardMyActivity;
import com.bykj.taketurns.myfragment.activity.ResetMyActivity;
import com.bykj.taketurns.myfragment.activity.SettingMyActivity;
import com.bykj.taketurns.myfragment.activity.WithdrawMyActivity;

import de.hdodenhof.circleimageview.CircleImageView;


/**
 * 类功能
 * Zhulei---
 * 2017/7/11
 */


public class MyFragment extends Fragment implements View.OnClickListener {

    private View mRootView;
    private ImageView iv_back_my;
    private CircleImageView iv_portrait_my;
    private boolean emulated;
    private TextView tv_name_my;
    private TextView tv_id_my;
    private TextView tv_signature_my;
    private TextView tv_attention_my;
    private TextView tv_fans_my;
    private TextView tv_praise_my;
    private Dialog alertDialog;


    public MyFragment() {

    }


    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        if (mRootView == null) {
            mRootView = inflater.inflate(R.layout.fragment_my, container, false);
        }
        ViewGroup parent = (ViewGroup) mRootView.getParent();
        if (parent != null) {
            parent.removeView(mRootView);
        }
        return mRootView;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initHeader();
        initWidget();
        setWidgetState();
    }

    private void initHeader() {

    }

    private void initWidget() {

        iv_back_my = getActivity().findViewById(R.id.iv_back_my);
        iv_portrait_my = getActivity().findViewById(R.id.iv_portrait_my);
        tv_name_my = getActivity().findViewById(R.id.tv_name_my);
        tv_id_my = getActivity().findViewById(R.id.tv_id_my);
        tv_signature_my = getActivity().findViewById(R.id.tv_signature_my);
        tv_attention_my = getActivity().findViewById(R.id.tv_attention_my);
        tv_fans_my = getActivity().findViewById(R.id.tv_fans_my);
        tv_praise_my = getActivity().findViewById(R.id.tv_praise_my);

        getActivity().findViewById(R.id.btn_attention_my).setOnClickListener(this);
        getActivity().findViewById(R.id.btn_fans_my).setOnClickListener(this);
        getActivity().findViewById(R.id.btn_praise_my).setOnClickListener(this);
        getActivity().findViewById(R.id.btn_play_my).setOnClickListener(this);
        getActivity().findViewById(R.id.btn_message_my).setOnClickListener(this);
        getActivity().findViewById(R.id.btn_property_my).setOnClickListener(this);
        getActivity().findViewById(R.id.btn_reset_my).setOnClickListener(this);
        getActivity().findViewById(R.id.btn_withdraw_my).setOnClickListener(this);
        getActivity().findViewById(R.id.btn_setting_my).setOnClickListener(this);
        getActivity().findViewById(R.id.btn_regard_my).setOnClickListener(this);
        iv_portrait_my.setOnClickListener(this);

    }

    @Override
    public void onClick(View view) {

        switch (view.getId()) {
            case R.id.btn_attention_my://关注
                startActivity(new Intent(getActivity(), AttentionActivity.class));
                break;
            case R.id.btn_fans_my://粉丝
                startActivity(new Intent(getActivity(), FansActivity.class));
                break;
            case R.id.btn_praise_my://得赞
                startActivity(new Intent(getActivity(), PraiseActivity.class));
                break;
            case R.id.iv_portrait_my://个人设置
                startActivity(new Intent(getActivity(), PersonageMyActivity.class));
                break;
            case R.id.btn_play_my://我的剧本
                startActivity(new Intent(getActivity(), PlayMyActivity.class));
                break;
            case R.id.btn_message_my://消息
                startActivity(new Intent(getActivity(), MessageMyActivity.class));
                break;
            case R.id.btn_property_my://财产
                startActivity(new Intent(getActivity(), PropertyMyActivity.class));
                break;
            case R.id.btn_reset_my://充值
                startActivity(new Intent(getActivity(), ResetMyActivity.class));
                break;
            case R.id.btn_withdraw_my://提现
                startActivity(new Intent(getActivity(), WithdrawMyActivity.class));
                break;
            case R.id.btn_setting_my://设置
                startActivity(new Intent(getActivity(), SettingMyActivity.class));
                break;
            case R.id.btn_regard_my://关于我们
                startActivity(new Intent(getActivity(), RegardMyActivity.class));
                break;
        }
    }

    private void setWidgetState() {

    }

    @Override
    public void onResume() {
        super.onResume();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        MyApplication.getRefWatcher(getActivity()).watch(this);
    }

    public TextView getTv_attention_my() {
        return tv_attention_my;
    }

    public void setTv_attention_my(TextView tv_attention_my) {
        this.tv_attention_my = tv_attention_my;
    }

    public TextView getTv_id_my() {
        return tv_id_my;
    }

    public TextView getTv_signature_my() {
        return tv_signature_my;
    }
}
